package com.gxuwz.attend.web.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 清除 session 中的用户数据
        HttpSession session = request.getSession();
        session.invalidate(); // 使当前会话无效

        // 重定向到登录页
        response.sendRedirect("http://localhost:8080/attend_war/login.jsp");
    }
}
